home *** CD-ROM | disk | FTP | other *** search
/ Nejlepší hry / Nejlepsi hry.iso / hry / sea of chaos / sea_install.msi / _15C39AAA7726369D39812BD40F01CF6A / _EF048D84920D4DC5A08EBE7556F16242 < prev    next >
Text File  |  2004-12-06  |  2KB  |  70 lines

  1. //dp logo swirl swirl
  2.  
  3. //Luke Lenhart
  4. //(C)2004-2005 Digipen Institute of Technology
  5.  
  6. //combined world,view,projection transform
  7. float4x4 matViewProj;
  8.  
  9. //animation position modifier (vary from 5 to 0)
  10. float mod;
  11.  
  12. //rotation around the z axis
  13. float hRot;
  14.  
  15. //shader input
  16. struct VS_INPUT
  17. {
  18.     float4 Pos : POSITION;
  19.     float4 Normal : NORMAL;
  20.     float2 Tex0 : TEXCOORD0;
  21. };
  22.  
  23. //shader output
  24. struct VS_OUTPUT
  25. {
  26.     float4 Pos : POSITION;
  27.     float3 Normal : TEXCOORD2;
  28.     float3 Pos2 : TEXCOORD1;
  29.     float2 Tex0 : TEXCOORD0;
  30.     float4 Color : COLOR;
  31. };
  32.  
  33. //shader code
  34. VS_OUTPUT VShader(VS_INPUT In)
  35. {
  36.     VS_OUTPUT Out;
  37.     Out.Normal=In.Normal;
  38.     
  39.     //copy tex coord
  40.     Out.Tex0=In.Tex0;
  41.     
  42.     //animation vertex position swirl
  43.     float dist=distance(In.Pos.xz,float2(0,0)); //dist from center
  44.     float theta=dist*0.25f*mod + 2.0f*mod; //make a rotation
  45.     float2x2 matRot={cos(theta),sin(theta),-sin(theta),cos(theta)};
  46.     float4 pos=In.Pos;
  47.     pos.xz=mul(matRot,In.Pos.xz);
  48.     Out.Normal.xz=mul(matRot,Out.Normal.xz);
  49.     
  50.     //scale
  51.     pos.xz*=mod+1.0f;
  52.     
  53.     //rotate around z axis (pos and normal)
  54.     matRot=float2x2(cos(hRot),sin(hRot),-sin(hRot),cos(hRot));
  55.     pos.xy=mul(matRot,pos.xy);
  56.     Out.Normal.xy=mul(matRot,Out.Normal.xy);
  57.     
  58.     //calc transformed position
  59.     Out.Pos=mul(matViewProj,pos);
  60.     Out.Pos2=pos;
  61.     
  62.     //calc alpha
  63.     float alpha=0.2f + 1.0f - mod*(1.0f/5.0f); //generally fade in from nothing
  64.     alpha-=0.1f*(dist*mod*mod)*0.2f; //middle fades in first
  65.     Out.Color=float4(1,1,1,alpha);
  66.     
  67.     //spit out the results
  68.     return Out;
  69. }
  70.